package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.Teacher;
import com.juneng.mapper.TeacherMapper;
import com.juneng.service.ITeacherService;
import com.juneng.dto.TeacherDto;
import com.juneng.dto.TeacherQueryDto;
import com.juneng.vo.TeacherVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 教师信息 服务实现类
 *
 * @author zds
 * @since 2021-07-30
 */
@Service
@AllArgsConstructor
public class TeacherServiceImpl implements ITeacherService {

    protected TeacherMapper teacherMapper;
    @Override
    public IPage<TeacherVo> page(TeacherQueryDto dto) {
        IPage<TeacherVo> page = Condition.getPage(dto);
        return teacherMapper.page(page,dto);
    }
      //reimburse
    @Override
    public List<Teacher> list(TeacherQueryDto dto) {
        QueryWrapper<Teacher> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,Teacher.class));
        return teacherMapper.selectList(queryWrapper);
    }
    // teacherCourseName
    @Override
    public Integer save(TeacherDto dto) {
        return teacherMapper.insert(BeanCopyUtils.copy(dto,Teacher.class));
    }

    @Override
    public Integer updateById(TeacherDto dto) {
        Teacher teacher = new Teacher();
        TeacherDto teacherDto = new TeacherDto();
        return teacherMapper.updateById(BeanCopyUtils.copy(dto,Teacher.class));
    }

    @Override
    public Integer deleteLogic(Long id) {
        return teacherMapper.deleteById(id);
    }

    @Override
    public Teacher getById(Integer id) {
        return teacherMapper.selectById(id);
    }
}
